#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

inline void advance(int *ref_c) {
    *ref_c = fgetc(stdin);
}

inline void produce(uint val) {
    printf("%d", val);
    exit(0);
}

int main(int argc, char ** argv) {
    // (0|[1-9][0-9]*)%

    uint state = 0;
    uint percent = 0;
    int c;

    advance(&c);
    while (true) {
        if (c == EOF) break;

        switch (state) {
        case 0:
            if (c == '0') {
                state = 1;
            } else if (c >= '1' && c <= '9') {
                percent = (uint)c - '0';
                state = 2;
            }
            advance(&c);
            break;
        case 1:
            if (c == '%') {
                produce(0);
            } else {
                state = 0;
            }
            break;
        case 2:
            if (c == '%') {
                produce(percent);
            } else if (c >= '0' && c <= '9') {
                percent = percent * 10 + ((uint)c - '0');
                advance(&c);
            } else {
                state = 0;
                // shortcut:
                advance(&c);
            }
            break;
        default:
            fprintf(stderr, "Internal Error: Unexpected state!");
            return -1;
        }
    }

    return 1;
}
